package com.sc.sc250601.cook.controller;

import com.sc.sc250601.cook.pojo.Category;
import com.sc.sc250601.cook.pojo.Result;
import com.sc.sc250601.cook.service.CategoryService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import java.util.List;

@RestController
@RequestMapping("/category")
public class CategoryController {
    @Autowired
    CategoryService cs;
    @RequestMapping("/selectAllTypeName")
    public Result selectAllTypeName(){
        List<String> tags=cs.selectAllTypeName();
        if(tags!=null){
            return new Result(1,"获取标签成功",tags);
        }
        return new Result(0,"获取标签失败");
    }

    /**
     * 获取所有分类
     *
     */
    @RequestMapping("/getAll")
    public Result getAll(){
        List<Category> categories =cs.getAll();
        if(categories.isEmpty()){
            return new Result(0,"暂无数据");
        }
        return new Result(1,"success",categories);
    }
}
